/**
 * form表单
 */
seajs.use(["zui/form"],function(Form){
	var form1 = 
			new Form({srcNode:"#CM_Form",validType:"custom",validateFunc:function(ev){
				var field=ev.field;
				var msg=ev.validateMsg;
				if(msg==""){

				}else{
				  	App.showToast(msg);
			  	}
		  	}});
	$("#zaw-btn").on("click",function(){
		if(form1.valid()){
			zaTool.zaDialog({title:'<div class="alert_right"></div>',msg:'绑定成功',duration: 1000},"alert");
			zaTool.zaDialog({title:'<div class="alert_error"></div>',msg:'绑定失败',duration: 1000},"alert");
			//$("#CM_Form").submit();
		}
	});
	$("#zaw-verCode").on("click",function(){
		if( $(this).attr("disabled") ){
			App.showToast("冷却中");
		}else{
			if( isRegist($("#mobile").val()) ){
				sendPhoneCode();
				
			}else{
				 
			}
		}
	});
});
//发送手机验证码，倒计时60秒
function sendPhoneCode(){
	var time=60;
	$("#zaw-verCode").attr("disabled","disabled");
	$("#zaw-verCode").text(+(time)+"秒后再发送!");
	var sInterval=setInterval(function(){
			time=time-1;
			$("#zaw-verCode").text(+(time)+"秒后再发送!");
			if(time==0){
				$("#zaw-verCode").removeAttr("disabled");
				clearInterval(sInterval);
				$("#zaw-verCode").text("获取验证码");
			}
	},1000);
};
//校验手机号格式，是否已注册
function isRegist(arg){
	re = new RegExp( /^0?(13[0-9]|15[012356789]|17[0-9]|18[02356789]|14[57])[0-9]{8}$/);
	if(!re.test(arg)){
		App.showToast('手机号码格式不正确');
		return false;
	}else {
		return true;
		// $.ajax({
		// 	type:"get",
		// 	async: false,
		// 	url:"/open/common/openScreen/isRegist.json",
		// 	data:{"mobilePhone":arg},
		// 	dataType:"json",
		// 	success:function(data){
		// 		if(data){
		// 			App.showToast('此账号已注册');
		// 		}
		// 	}
		// });
	}
}